package invalidj2eebusinesscomponentdependency;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import invalidj2eebusinesscomponentdependency.InvalidJ2eeBusinessComponentDependencyMatch;
import invalidj2eebusinesscomponentdependency.InvalidJ2eeBusinessComponentDependencyMatcherFactory;
import invalidj2eebusinesscomponentdependency.InvalidJ2eeBusinessComponentDependencyMatcher;

public class InvalidJ2eeBusinessComponentDependencyConstraint extends Constraint<InvalidJ2eeBusinessComponentDependencyMatch> {

	private InvalidJ2eeBusinessComponentDependencyMatcherFactory matcherFactory;

	public InvalidJ2eeBusinessComponentDependencyConstraint() {
		matcherFactory = new InvalidJ2eeBusinessComponentDependencyMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "$j2eeComponent.name$ J2EE business business component should not depend from $otherComponent.name$ business component, cause it is implemented with another technology!";
	}

	@Override
	public EObject getLocationObject(InvalidJ2eeBusinessComponentDependencyMatch signature) {
		Object location = signature.get("j2eeComponent");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<InvalidJ2eeBusinessComponentDependencyMatch, InvalidJ2eeBusinessComponentDependencyMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
